<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class SecurityHook extends CI_Hooks {

    public function redirectIfNotLoggedIn() {
        if (!get_instance()->tank_auth->is_logged_in() && !$this->startsWith(uri_string(), "auth/")) {
            redirect("/auth/login");
        }
    }

    function startsWith($haystack, $needle) {
        $length = strlen($needle);
        return (substr($haystack, 0, $length) === $needle);
    }
}
